const express = require('express')
const router = express.Router()
const departmentController = require('../controllers/department')
const auth = require('../middleware/auth')

router.use(auth)

// 获取部门树
router.get('/tree', departmentController.getTree)

// 获取预分配的部门编码
router.get('/generate-code', departmentController.generateCode)

// 获取权限模板列表
router.get('/templates', departmentController.getTemplates)

// 更新部门排序
router.put('/order', departmentController.updateOrder)

// 创建部门
router.post('/', departmentController.create)

// 更新部门
router.put('/:id', departmentController.update)

// 删除部门
router.delete('/:id', departmentController.delete)

// 获取部门详情
router.get('/:id', departmentController.getById)

module.exports = router 